package name.as3.frameworkTest.view
{
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldType;

import name.as3.frameworkTest.events.LoginEvent;
import name.as3.frameworkTestSupport.ui.controls.TestAlert;
import name.as3.simpleUIComponents.controls.SimpleUIButton;
import name.as3.simpleUIComponents.core.SimpleSprite;

public class LoginPanel extends SimpleSprite
{
	private var m_btn:SimpleUIButton;
	private var m_ttf:TextField;
	/**
	 *
	 */
	public function LoginPanel()
	{
		super();
		graphics.beginFill(0xff0088, .8);
		graphics.drawRoundRect(0, 0, 230, 120, 8, 8);
		graphics.endFill();
		_init();
		super.addChild(m_ttf);
		super.addChild(m_btn);
		m_btn.addEventListener(MouseEvent.CLICK, click_btn);
	}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// event
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
	private function click_btn(e:MouseEvent):void
	{
		var event:LoginEvent = new LoginEvent(LoginEvent.REQUEST_LOGIN);
		event.userName = m_ttf.text;
		this.dispatchEvent(event);
	}
	override public function onGlobalInited():void
	{
		TestAlert(sgs()).show(">> ");
	}
//==================================================================================================
// public
//==================================================================================================
	public function set userName(value:String):void
	{
		m_ttf.text = value;
	}
//--------------------------------------------------------------------------------------------------
// private
//--------------------------------------------------------------------------------------------------
	private function _init():void
	{
		m_ttf = new TextField();
		m_ttf.type = TextFieldType.INPUT;
		m_ttf.border = true;
		m_ttf.background = true;
		m_ttf.x = 15;
		m_ttf.y = 20;
		m_ttf.width = 200;
		m_ttf.height = 20;
		/*
		*/
		m_btn = new SimpleUIButton();
		m_btn.text = "登录";
		m_btn.x = 150;
		m_btn.y = 100;
	}
}
}